Skip to content

fix(id): memoize host-view records revision per snapshot (#9104) - #9152

Merged
dezren39 merged 1 commit into
mainfrom
queue/15343-9104-hostview-revision
Nov 13, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/15343-9104-hostview-revision

Conversation

@dezren39

@dezren39 dezren39 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #9104.

Change

pkgs/id/src/web/world_ws.rs only:

  • The FNV-1a full-map hash is kept verbatim as hash_records_revision — revision values for a given records set are unchanged.
  • records_revision now memoizes that hash in a bounded cache (RecordsRevisionCache, max 8 entries) keyed by the published snapshot's Arc<Records>. publish_records swaps the Arc only when the records actually change, so Arc identity is exact snapshot identity; the cache holds the Arc, so a pointer can never be recycled by a different snapshot while its revision is cached. Host-view paging now pays the full-map serialize+hash once per published snapshot instead of once per page request.
  • The 768 KiB page limit, the paging loop, and change-during-paging behavior are untouched: a changed records set is a new Arc and hashes to a new revision on its first page.

Tests

  • New records_revision_is_computed_once_per_snapshot_across_pages: a 200-entry × 8 KiB (~1.6 MiB, multi-page) records set; a counting wrapper around the real hash tallies exactly 1 computation across 5 simulated page requests, and exactly 1 more after a change produces a new snapshot with a different revision.
  • New records_revision_cache_is_bounded: the memo never exceeds its cap.

Verification limits (pre-existing, not this diff)

The web feature facade does not compile at main for unrelated reasons (filed as #9151: host_view/MAX_RECORDS_PAGE_BYTES/encode_hex are pub(crate) in id-worlds, world_hub::testing is cfg(test)-only, etc. — reproduced on clean main with this diff stashed). So the new unit tests cannot yet run in-tree. Verified instead:

  • The cache logic (copied verbatim, hash stubbed) compiles under rustc and both test scenarios pass standalone.
  • cargo check -p id --lib (default features) passes; rustfmt --edition 2024 --check on the file is clean; the diff touches only world_ws.rs.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 13, 2026 01:13
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1efc4fa8-ba2e-4854-b414-942dafe3331d
Commits

Reviewing files that changed from the base of the PR and between b7cc3a8 and 7f088e3.

Files selected for processing: 1

  • pkgs/id/src/web/world_ws.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T01:14:57.982985Z 7f088e3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(id/web): avoid reserializing all records on every host-view page

1 participant